﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class UIAP04M:UIAPKOPF
    {
        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dwMaster == null)
                    return;
                TMV.APKZUSATZKZ1 = TMV.APKZUSATZKZ1.Trim().PadRight(1);
                TMV.APKZUSATZKZ2 = TMV.APKZUSATZKZ2.Trim().PadRight(1);
                TMV.APKZUSATZKZ3 = TMV.APKZUSATZKZ3.Trim().PadRight(1);
                TMV.APKZUSATZKZ4 = TMV.APKZUSATZKZ4.Trim().PadRight(1);
                TMV.APKGZUSKZ1 = TMV.APKGZUSKZ1.Trim().PadRight(1);
                TMV.APKGZUSKZ2 = TMV.APKGZUSKZ2.Trim().PadRight(1);
                TMV.APKGZUSKZ3 = TMV.APKGZUSKZ3.Trim().PadRight(1);
                TMV.APKGZUSKZ4 = TMV.APKGZUSKZ4.Trim().PadRight(1);
                TMV.UpdateAPKOPF(dwMaster, 0);
                base.SaveCommand(sender, e);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        public void ARTCommand(object sender, RoutedEventArgs e)
        {
            DES = "";
            DES = "F" + ART + VAR + FARBE + FINISH + DESS + COLORIT;
        }


        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 6)
                return;
            ORDERNUM = "";
            ORDERNUM = EXAUF.Substring(0, 8);
            if (!IsAuto)
                return;
            if (TBMain.Rows.Count > 0)
                return;
            PM["ARTST"] = "F";
            PM["KRS"] = EXAUF.Substring(0,2);
            PM["LFD"] = EXAUF.Substring(2, 6);
            PM["DES"] = EXAUF;
            PM["SPSTA"] = "T";
            PM["SPGRD"] = EXAUF.Substring(0, 6 + 15).PadRight(30);
            TMV.NEWAPK(PM);
            vwMaster.View.MoveCurrentToFirst();
            base.OnEXAUFChg(vlaue);
        }
    }
    
}
